using System;

namespace OpenRay
{
	public delegate float[] ColorFunc(float[] point);
	
	public class ProceduralColor : IProceduralColor
	{
		private readonly ColorFunc func;
		
		public ProceduralColor (ColorFunc f)
		{
			func = f;
		}
		
		public Color Evaluate (Point modelHit)
		{
			float[] temp = new float[3] { modelHit.X, modelHit.Y, modelHit.Z };
			temp = func(temp);
			
			if (temp.Length != 4)
				throw new System.ApplicationException("Returned array from procedural color function was not of length 4");
			
			return new Color( temp[0], temp[1], temp[2], temp[3] );
		}
	}
}

